package data;

public class Candidate
{
    // name contains [id REALNAME]
    private String _name;
    private boolean _isVoted;

    public Candidate( String name, boolean isVoted )
    {
        _name = name;
        _isVoted = isVoted;
    }

    public Candidate( String name )
    {
        this( name, false );
    }

    public void vote()
    {
        _isVoted = true;
    }

    public void unvote()
    {
        _isVoted = false;
    }

    public String getName()
    {
        return _name;
    }

    public boolean isVoted()
    {
        return _isVoted;
    }

    public String toString()
    {
        return _name + " " + ( _isVoted? 't' : 'f' );
    }

    public int hashCode()
    {
        return _name.hashCode();
    }

    public boolean equals( Object o )
    {
        if( o instanceof Candidate )
        {
            Candidate reflected = (Candidate)o;
            if( _name.equals( reflected.getName() ) )
                return true;
        }
        return false;
    }
}
